﻿define('data/customers', ['data', 'root'], function (data, root) {
    var Customer = function(fromServer) {
        fromServer = fromServer || {};
        var self = this;
        self.Id = fromServer.Id || 0;
        self.Name = ko.observable(fromServer.Name).extend({ required: true });
        self.Description = ko.observable(fromServer.Description);
    };

    var ListCustomer = function(fromServer) {
        $.extend(this, fromServer);
        this.isDeleting = ko.observable(false);
        var addDate = moment(this.CreateDate);
        this.CreateDate = addDate.format('MMMM Do YYYY');
    };

    return $.extend(new data.Crud('customers'), {
        Customer: Customer,
        ListCustomer: ListCustomer,
        LookupLink: root + 'customers/lookup'
    });
});